<?php

class AttEmployeeHandler{

private $emppno;
private $attyear;
private $attmonth;
private $con; 

public function setEmpno($emp){
	$this->empno=$emp;

}

public function setAttyear($atty){
	
	$this->attyear=$atty;
}

public  function setAttmonth($attm){

    $this->attmonth=$attm;
}


public function setConnect($conn){

	$this->con=$conn;
}



public function attAdd($day,$in,$out){


$sql="insert into employee_attend (emp_no,attend_date,inn,outt) values('$this->empno','$day','$in','$out')";

$result=mysql_query("select * from employee where emp_no='$this->empno' ",$this->con) or die(mysql_error());

$count=mysql_num_rows($result);

if(!($count==0)){

mysql_query($sql,$this->con) or die(mysql_error());

$msg="Succeessfully Added";

return $msg;

} else {

$msg="Invalid Employee No ";

return $msg;

}
}


public function getPageSearch($startrow,$limit){


$sql="select * from employee_attend order by att_id desc limit $startrow,$limit";

$result= mysql_query($sql,$this->con) or die(mysql_error()); 

return $result;

  }
  
  public function getSearch($startrow,$limit){
  
 

$sql="select * from employee_attend  where emp_no='$this->empno' and year(attend_date)='$this->attyear' and month(attend_date)='$this->attmonth' order by att_id desc limit $startrow,$limit";

$result= mysql_query($sql,$this->con) or die(mysql_error()); 

return $result;

  
  
  
  } 
  
  
  public function getDelete($id){
  
  //include'db.php';
  
  //$w=new Dbconnect();
  
  //$con=$w->getConnection();
  
  $sql="delete from employee_attend where att_id='$id'";
  
  //mysql_query($sql,$con);
   mysql_query($sql,$this->con) or die(mysql_error());
  
  $msg="deleted";
  
  return $msg; 
 
  
  }
  
  
  public function attUpdate($id,$day,$in,$out){
  
  
  
  $sql="update employee_attend set emp_no='$this->empno',attend_date='$day',inn='$in',outt='$out' where att_id='$id' ";
  
  mysql_query($sql,$this->con) or die(mysql_error()); 
  
  $msg="  Successfully Updated";
  
  return $msg;
  
  }
  


public function getPaginationRow(){
 
 $sql="select * from employee_attend  where emp_no='$this->empno' and year(attend_date)='$this->attyear' and month(attend_date)='$this->attmonth' ";

$result= mysql_query($sql,$this->con) or die(mysql_error()); 

return $result;
  
  } 


} 


 ?>